<!--   [PAGE]] : 个人项目模板
       @Author  : ljq
       @Created : 2025/10/8
 -->
<template>
  <div class="app-container">
    <!-- ------------------------ START: 查询框 -------------------------->
    <el-form class='query' :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="项目关联ID">
        <select-project v-model="queryParams.params.projectIdList" placeholder="请选择项目关联ID"/>
      </el-form-item>
      <el-form-item label="用户关联ID">
        <select-user v-model="queryParams.params.userIdList" placeholder="请选择用户关联ID"/>
      </el-form-item>
      <el-form-item label="银行卡关联ID">
        <select-bank-card v-model="queryParams.params.bankCardIdList" placeholder="请选择银行卡关联ID"/>
      </el-form-item>
      <el-form-item label="计划上班时间区间">
        <el-input  v-model="queryParams.params.planWorkTimeRangeLike"  placeholder="请输入计划上班时间区间"  clearable  @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="实际上班时间">
        <el-date-picker v-model="queryParams.params.realWorkStartAtRange"  style="width: 240px"  value-format="yyyy-MM-dd HH:mm:ss" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"/>
      </el-form-item>
      <el-form-item label="实际下班时间">
        <el-date-picker v-model="queryParams.params.realWorkEndAtRange"  style="width: 240px"  value-format="yyyy-MM-dd HH:mm:ss" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"/>
      </el-form-item>
      <el-form-item label="计划工时">

      </el-form-item>
      <el-form-item label="实际工时">

      </el-form-item>
      <el-form-item label="备注">
        <el-input  v-model="queryParams.params.commentLike"  placeholder="请输入备注"  clearable  @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="状态">
        <el-select v-model="queryParams.status" placeholder="状态" filterable clearable>
          <el-option  v-for="dict in dict.type.字典v" :key="dict.value" :label="dict.label" :value="dict.value"/>
        </el-select>
      </el-form-item>
      <el-form-item label="审批人">
        <select-user v-model="queryParams.params.approvalByList" placeholder="请选择审批人"/>
      </el-form-item>
      <el-form-item label="时薪">

      </el-form-item>
      <el-form-item label="工种">
        <el-input  v-model="queryParams.params.workTypeLike"  placeholder="请输入工种"  clearable  @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker v-model="queryParams.params.createTimeRange"  style="width: 240px"  value-format="yyyy-MM-dd HH:mm:ss" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"/>
      </el-form-item>
      <el-form-item label="更新时间">
        <el-date-picker v-model="queryParams.params.updateTimeRange"  style="width: 240px"  value-format="yyyy-MM-dd HH:mm:ss" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"/>
      </el-form-item>
      <el-form-item label="创建者">
        <el-input  v-model="queryParams.params.createByLike"  placeholder="请输入创建者"  clearable  @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="更新者">
        <el-input  v-model="queryParams.params.updateByLike"  placeholder="请输入更新者"  clearable  @keyup.enter.native="handleQuery"/>
      </el-form-item>

      <el-form-item class="option">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- ------------------------- END: 查询框 --------------------------->

    <!-- ---------------------- START: 主数据区域------------------------->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['business:projectDetailTemplate:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['business:projectDetailTemplate:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['business:projectDetailTemplate:remove']">删除</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"/>
    </el-row>


    <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="50" align="center"/>
      <el-table-column label="编号" align="center" prop="id" v-if="columns[0].visible"/>
      <el-table-column label="项目关联ID" align="center" prop="projectId" v-if="columns[1].visible">
        <template slot-scope="scope">
          <select-project ：col="true"  :value="scope.row.projectId"/>
        </template>
      </el-table-column>
      <el-table-column label="用户关联ID" align="center" prop="userId" v-if="columns[2].visible">
        <template slot-scope="scope">
          <select-user ：col="true"  :value="scope.row.userId"/>
        </template>
      </el-table-column>
      <el-table-column label="银行卡关联ID" align="center" prop="bankCardId" v-if="columns[3].visible">
        <template slot-scope="scope">
          <select-bank-card ：col="true"  :value="scope.row.bankCardId"/>
        </template>
      </el-table-column>
      <el-table-column label="计划上班时间区间" align="center" prop="planWorkTimeRange" v-if="columns[4].visible"/>
      <el-table-column label="实际上班时间" align="center" prop="realWorkStartAt" v-if="columns[5].visible"/>
      <el-table-column label="实际下班时间" align="center" prop="realWorkEndAt" v-if="columns[6].visible"/>
      <el-table-column label="计划工时" align="center" prop="planHour" v-if="columns[7].visible"/>
      <el-table-column label="实际工时" align="center" prop="realHour" v-if="columns[8].visible"/>
      <el-table-column label="备注" align="center" prop="comment" v-if="columns[9].visible"/>
      <el-table-column label="状态" align="center" prop="status" v-if="columns[10].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.字典v" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="审批人" align="center" prop="approvalBy" v-if="columns[11].visible">
        <template slot-scope="scope">
          <select-user ：col="true"  :value="scope.row.approvalBy"/>
        </template>
      </el-table-column>
      <el-table-column label="时薪" align="center" prop="hourlyWage" v-if="columns[12].visible"/>
      <el-table-column label="工种" align="center" prop="workType" v-if="columns[13].visible"/>
      <el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[14].visible"/>
      <el-table-column label="更新时间" align="center" prop="updateTime" v-if="columns[15].visible"/>
      <el-table-column label="创建者" align="center" prop="createBy" v-if="columns[16].visible"/>
      <el-table-column label="更新者" align="center" prop="updateBy" v-if="columns[17].visible"/>
      <el-table-column label="删除标志" align="center" prop="delFlag" v-if="columns[18].visible"/>
      <el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[19].visible"/>
      <el-table-column label="创建者"   align="center" prop="createBy"   v-if="columns[20].visible"/>
      <el-table-column label="更新时间" align="center" prop="updateTime" v-if="columns[21].visible"/>
      <el-table-column label="更新者"   align="center" prop="updateBy"   v-if="columns[22].visible"/>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
    <!-- ---------------------- END: 主数据区域 ------------------------>

    <!-- ------------------------ START: 弹出框 -------------------------->
    <el-dialog :title="title" :visible.sync="open" width="780px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目关联ID" prop="projectId">
              <select-project v-model="form.projectId" placeholder="请选择项目关联ID"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="用户关联ID" prop="userId">
              <select-user v-model="form.userId" placeholder="请选择用户关联ID"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="银行卡关联ID" prop="bankCardId">
              <select-bank-card v-model="form.bankCardId" placeholder="请选择银行卡关联ID"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划上班时间区间" prop="planWorkTimeRange">
              <el-input v-model="form.planWorkTimeRange" placeholder="请输入计划上班时间区间"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际上班时间" prop="realWorkStartAt">
              <el-date-picker clearable v-model="form.realWorkStartAt" type="date"  value-format="yyyy-MM-dd HH:mm:ss" placeholder="请输入实际上班时间"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际下班时间" prop="realWorkEndAt">
              <el-date-picker clearable v-model="form.realWorkEndAt" type="date"  value-format="yyyy-MM-dd HH:mm:ss" placeholder="请输入实际下班时间"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划工时" prop="planHour">
              <el-input v-model="form.planHour" placeholder="请输入计划工时"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际工时" prop="realHour">
              <el-input v-model="form.realHour" placeholder="请输入实际工时"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="comment">
              <el-input v-model="form.comment" placeholder="请输入备注"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="状态" prop="status">
              <el-select v-model="form.status" placeholder="状态"  filterable  clearable>
                <el-option  v-for="dict in dict.type.字典v" :key="dict.value" :label="dict.label" :value="dict.value"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审批人" prop="approvalBy">
              <select-user v-model="form.approvalBy" placeholder="请选择审批人"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="时薪" prop="hourlyWage">
              <el-input v-model="form.hourlyWage" placeholder="请输入时薪"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工种" prop="workType">
              <el-input v-model="form.workType" placeholder="请输入工种"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="创建时间" prop="createTime">
              <el-date-picker clearable v-model="form.createTime" type="date"  value-format="yyyy-MM-dd HH:mm:ss" placeholder="请输入创建时间"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="更新时间" prop="updateTime">
              <el-date-picker clearable v-model="form.updateTime" type="date"  value-format="yyyy-MM-dd HH:mm:ss" placeholder="请输入更新时间"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="创建者" prop="createBy">
              <el-input v-model="form.createBy" placeholder="请输入创建者"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="更新者" prop="updateBy">
              <el-input v-model="form.updateBy" placeholder="请输入更新者"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="删除标志" prop="delFlag">
              <el-input v-model="form.delFlag" placeholder="请输入删除标志"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- ------------------------ END: 弹出框 -------------------------->
  </div>
</template>
<script>
import {listProjectDetailTemplate, getProjectDetailTemplate, addProjectDetailTemplate, updateProjectDetailTemplate, delProjectDetailTemplate} from "@/api/business/projectDetailTemplate";
import {initData,  baseMethods} from "@/utils/basePage";

import SelectProject from "@/components/Selector/SelectProject";
import SelectUser from "@/components/Selector/SelectUser";
import SelectBankCard from "@/components/Selector/SelectBankCard";

let baseData = initData();
export default {
  name: "ProjectDetailTemplate",
  dicts: ['字典v'],
  components: {SelectProject,SelectUser,SelectBankCard},
  data() {
    return {
      ...baseData,
      // 列信息
      columns: [
        { key: 0, label: `编号`, visible: true },
        { key: 1, label: `项目关联ID`, visible: true },
        { key: 2, label: `用户关联ID`, visible: true },
        { key: 3, label: `银行卡关联ID`, visible: true },
        { key: 4, label: `计划上班时间区间`, visible: true },
        { key: 5, label: `实际上班时间`, visible: true },
        { key: 6, label: `实际下班时间`, visible: true },
        { key: 7, label: `计划工时`, visible: true },
        { key: 8, label: `实际工时`, visible: true },
        { key: 9, label: `备注`, visible: true },
        { key: 10, label: `状态`, visible: true },
        { key: 11, label: `审批人`, visible: true },
        { key: 12, label: `时薪`, visible: true },
        { key: 13, label: `工种`, visible: true },
        { key: 14, label: `创建时间`, visible: true },
        { key: 15, label: `更新时间`, visible: true },
        { key: 16, label: `创建者`, visible: true },
        { key: 17, label: `更新者`, visible: true },
        { key: 18, label: `删除标志`, visible: true },
        { key: 19, label: `创建时间`, visible: true },
        { key: 20, label: `创建者`,   visible: false },
        { key: 21, label: `更新时间`, visible: false },
        { key: 22, label: `创建者`,   visible: false },
      ],
      // 表单校验
      rules:{
        planWorkTimeRange:[{ required: true, message: "计划上班时间区间不能为空", trigger: "blur" }],
        realWorkStartAt:[{ required: true, message: "实际上班时间不能为空", trigger: "blur" }],
        realWorkEndAt:[{ required: true, message: "实际下班时间不能为空", trigger: "blur" }],
        planHour:[{ required: true, message: "计划工时不能为空", trigger: "blur" }],
        realHour:[{ required: true, message: "实际工时不能为空", trigger: "blur" }],
        comment:[{ required: true, message: "备注不能为空", trigger: "blur" }],
        status:[{ required: true, message: "状态不能为空", trigger: "blur" }],
        approvalBy:[{ required: true, message: "审批人不能为空", trigger: "blur" }],
        hourlyWage:[{ required: true, message: "时薪不能为空", trigger: "blur" }],
        delFlag:[{ required: true, message: "删除标志不能为空", trigger: "blur" }],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    ...baseMethods(listProjectDetailTemplate, getProjectDetailTemplate, addProjectDetailTemplate, updateProjectDetailTemplate, delProjectDetailTemplate),
  }
};
</script>
